<pre><?php

set_time_limit  ( 30 );
$time_start = microtime(true);
$GlobalNatives = Array();
$GlobalEnums = Array();
$GlobalDefines = Array();

$QueriesExecuted = 0;

function db_query($query){
 	global $QueriesExecuted;
 	
 	$QueriesExecuted++;
 
	$result = mysql_query($query);
	
	if (!$result) {
		echo 'Invalid query: ' . mysql_error() . "\n";
		echo 'Whole query: ' . $query;
		echo "\n\n\n";
		die();
	}
	
	return $result;
}

function GetBuild(){
	return GetVersion();
}

function GetVersion(){
	global $GlobalDefines;
	
	if(isset($GlobalDefines['SOURCEMOD_VERSION'])){
		return str_replace('"','', $GlobalDefines['SOURCEMOD_VERSION']->Value);
	}
	
	return "0";
}


class IncludeFile{
 	var $MysqlId = -1;
	var $FileName;
	var $FilePlace;
	var $FileContent;
	
	var $Name;
	
	var $Natives = Array();
	var $Enums = Array();
	var $Defines = Array();
		
		
	function MysqlInsert(){
		db_query('INSERT INTO `sm_files`(`name`,`NumNatives`,`NumEnums`,`NumDefines`,`content`) VALUES (
			\''. $this->Name .'\','.count($this->Natives).','.count($this->Enums).','.count($this->Defines).',\''. 
			mysql_real_escape_string( implode( $this->FileContent) ) .'\')');
		
		$this->SetMysqlId( mysql_insert_id() );
	}
	
	function MysqlUpdate(){
	 	if($this->MysqlId == -1) return;
	 
		db_query('UPDATE `sm_files` SET 
			`NumNatives` = '. count($this->Natives) .',
			`NumEnums` = '. count($this->Enums) .',
			`NumDefines` = '. count($this->Defines) .',
			`content` = \''. mysql_real_escape_string( implode( $this->FileContent ) ) .'\'
			WHERE id = '. $this->MysqlId .'
		');
	}
	
	function SetMysqlId( $id ){
		$this->MysqlId = $id;
	}
	
	
	function SetFile($file){
	 	global $GlobalNatives, $GlobalEnums, $GlobalDefines;
	 
	 	$this->Place = $file;
		$this->Name = basename($file, ".inc");
		$this->FileContent = file( $file );
		
		$lastcomment = 0;
		
		foreach($this->FileContent as $line_num => $line){
		 	//Until #31, it is just the GNU
		 	if($line_num <= 31) continue;
		 
		 
		 	$line = trim($line);
		 	
		 	
		 	if(substr($line, 0, 3) == "/**"){
				$lastcomment = $line_num;
				continue;
			}
		 
		 
			$space = strpos($line, " ");
			$decl = substr($line, 0, $space);
			
			switch($decl){
				case "native":
				case "stock":
				case "functag":
				case "forward":
				//case "funcenum": //TODO: ADD FUNCENUM SUPPORT
					
					$newnative = new NativeFunction;
					
					$newnative->Parent($this);
					$newnative->SetLines($lastcomment, $line_num, array_search( $decl, Array('native', 'stock', 'functag', 'funcenum','forward')));
					
					$this->Natives[ $newnative->Name ] = $newnative;
					$GlobalNatives[ $newnative->Name ] = $newnative;
				
					$lastcomment = 0;
					
					break;
				
				case "enum":
					
					$newenum = new Enum;
					$newenum->Parent($this);
					$newenum->SetLines($lastcomment, $line_num);
					
					$this->Enums[ $newenum->Name ] = $newenum;
					$GlobalEnums[ $newenum->Name ] = $newenum;
					
					$lastcomment = 0;
				
					break;
					
				case "#define":
					//echo $line . "<br>";
				
					$newdefine = new Define;
					$newdefine->Parent($this);
					
					if($newdefine->SetLine($line_num)){
						$this->Defines[$newdefine->Name] = $newdefine;
						$GlobalDefines[$newdefine->Name] = $newdefine;
					}
				
					break;
			}
		}
		
		
	}
}

class Define{
	var $Name;
	var $Value;
	var $Description = "";
	
	var $EnumParent = -1; //-1 = #define, other values (class target) = from a enum
	
	var $line;
	
	function GetInsertQuery(){
		return sprintf("REPLACE INTO `sm_defines`(`name`, `value`, `description`,`line`,`parent`,`enum`) VALUES
			('%s','%s','%s',%d,%d,%d)",
			mysql_real_escape_string($this->Name),
			mysql_real_escape_string($this->Value),
			mysql_real_escape_string($this->GetDescription()),
			$this->line,
			$this->Parent()->MysqlId,
			$this->GetEnumParent()
		);		
	}	
	
	function DoSuperQuery(){
		$query = $this->GetInsertQuery();
		
		$result = db_query( $query );		
	}
	
	function GetEnumParent(){
		if(is_object($this->EnumParent)) 
			return $this->EnumParent->MysqlId;
		return -1;
	}
	
	function GetDescription(){
	 
	 	if(is_string($this->Description)) return $this->Description;
	 	
		return implode("\n", $this->Description);
	}
	
	function ParentId(){
		return $this->Parent()->MysqlId;
	}
	
 	private $parent;
	function Parent($who = ''){
		if($who != ''){
			$this->parent = $who;
			return;
		}
		
		return $this->parent;
	}
	
	function SetLine($start){
	 	$line = $this->Parent()->FileContent[ $start ];
	 	$this->line = $start;
	 	
	 	$line = str_replace("*/", "", $line);
		$line = str_replace("\x09", " ", $line);
	 
		$Exploded = explode(" ", $line);
		
		
		
		
		if(substr(trim($line), -9,9) == "_included" || $line[0] == " "){
		 	//No _include defines
			return false;
		}		
		
		
		$CommentStart = strpos($line, "//");
		$commentlenght = 2;
		
		if($CommentStart === FALSE){
		 	$CommentStart = strpos($line, "/**<");
		 	$commentlenght = 4;
		}
				
		if($CommentStart === FALSE){
			$CommentStart = strpos($line, "/*");
			$commentlenght = 2;
		} 
		
		
		$this->Name = $Exploded[1];
		$valuestart = strpos($line, $this->Name) + strlen($this->Name);
		
		
	 	if($CommentStart !== FALSE){
			$this->Description = trim(substr($line, $CommentStart + $commentlenght));	
			
			$valueend = $CommentStart - $valuestart;
			
			$this->Value = trim(substr($line, $valuestart, $valueend));	
				
		} else {
			$this->Value = trim(substr($line, $valuestart));	
		}
		
		$this->Name = trim($this->Name);
	 
	 	return true;
	}
	
	
	
	function FromEnum($file, $enum, $line, $name, $value, $comment){
	 	global $GlobalDefines;
	 	
	 	$GlobalDefines[ $name ] = $this;
	 	$enum->Values[ $name ] = $this;
	 	$file->Defines[ $name ] = $this;
	 	 
		$this->Name = $name;
		$this->Value = $value;
		$this->Description = $comment;	
		$this->EnumParent = $enum; 
		$this->Parent($file);
		$this->line = $line;	
	}
	
	
}


class Enum{
 	//[0] = Starts
 	//[1] = comment end
 	//[2] = Actual end
 	var $LineNum = Array();
 	
 	var $MysqlId = -1;
 
 
 	var $Name = "";
 	var $Description = Array();
 	
 	
 	var $Values = Array(); //Array of Define objects
 	
 	private $parent;
	
	
	function Parent($who = ''){
		if($who != ''){
			$this->parent = $who;
			return;
		}
		
		return $this->parent;
	}
	
	function ParentId(){
		return $this->Parent()->MysqlId;
	}
	
	function GetDescription(){
		return implode("\n", $this->Description);
	}
	
	function GetInsertQuery(){
		return sprintf("REPLACE INTO `sm_enums`(`name`, `description`, `count`,`line`,`parent`,`version`,`build`) VALUES
			('%s','%s',%d,%d,%d,'%s',%d)",
			mysql_real_escape_string($this->Name),
			mysql_real_escape_string($this->GetDescription()),
			count($this->Values),
			$this->LineNum[0],
			$this->Parent()->MysqlId,
			GetVersion(),
			GetBuild()
		);		
	}
	
	
	function DoSuperQuery(){
		$query = $this->GetInsertQuery();
		
		$result = db_query( $query );		
	}
	
	function SetLines($start, $end){
		if($start == 0){
			$start = $end;
		}
		
		$this->LineNum[0] = $start;
		$this->LineNum[1] = $end;
		
		for($i = $start; $i <= $end; $i++){
		 	if(!isset($this->Parent()->FileContent[ $i ])) break;
	 
	 		$line = $this->Parent()->FileContent[ $i ];
	 		
	 		if( $i == $end && strpos( $line, '}' ) === FALSE){
				$end++;
			}

	 	}
	
	 	$this->LineNum[2] = $end;
	 	
	 	$this->Name = trim( substr( $this->Parent()->FileContent[ $this->LineNum[1] ], 5) );
	 	
	 	$InComment = false;
	 	$HasDefine = false;
	 	//For those who has no value specified, it just goes 0,1,2,3....
	 	$CurrentValue = 0;
	 	$MultiLineComment = false;
	 	
	 	
	 	$PerComment = Array();
	 	$VariableName = "";
	 	$Value = 0;	 	
	 	
	 	for($i = $this->LineNum[0]; $i <= $this->LineNum[2]; $i++){
	 		$line = $this->Parent()->FileContent[ $i ];
	 		
	 		$trimmed = trim($line);
	 		
	 		if($trimmed == "/* --- */") continue;
	 		
	 		if(substr($line, 0, 7) == "#define"){
	 		 	$HasDefine = true;
			  	continue;
			}			
			
			if(substr($line, 0, 4) == "enum"){
			  $this->Description = $PerComment;
			  $PerComment = Array();
			 	$HasDefine = false;
				continue;
			}
			
			//"PropFieldType" has some "#define" between the description and the "enum"
			if($HasDefine) continue;
			
			
			if($MultiLineComment == true){
			   $NewPerComment = trim( $line );
			   $CommentEnd = strpos($NewPerComment, "*/");
			   
				if($CommentEnd === FALSE){
            		$PerComment[] = $NewPerComment;
            		continue;
         		}
         
         
	         	$NewPerComment = substr( $NewPerComment, 0, $CommentEnd - 1);
	         
	         	if(strlen($NewPerComment) > 0 && $trimmed != "*/")
	            	$PerComment[] = $NewPerComment;
				   
				//$this->Values[ $VariableName ] = Array( $Value, $PerComment );
				$newdefine = new Define;
				$newdefine->FromEnum($this->Parent(), $this, $i, $VariableName, $Value, $PerComment);
				
				
	         	$PerComment = Array();
	         	$Value = 0;
	         	$VariableName = "";
	         	$MultiLineComment = false;
	         
	         	continue;
			}
			
	
	 		
	 		if($trimmed == "/**"){
				$InComment = true;
				continue;
			}
	 		if($trimmed == "*/"){
				$InComment = false;
				continue;
			}
			
			if($InComment){
			 	//Start reading after "* "
				$PerComment[] = trim( substr( $line, strpos($line, "*") + 1 ) );
			}
			
			//No empty lines
			if(strlen($trimmed) == 0) continue; 
	 		
	 		
	 		if(!$InComment){
				if($trimmed == "{" || $trimmed == "};" || $trimmed == "}") continue;
				
				$CommentLenght = 4;
				//Find the comment
				$CommentStart = strpos($line, "/**<");
				if($CommentStart === FALSE){
		          $CommentStart = strpos($line, "/*");
		          $CommentLenght = 2;
        		}
				
				
				$CommentEnd = strpos($line, "*/");
				$CommaPos = strpos($line, ",");
				$Equal = strpos($line, "=");
				
				//Not read commas or = in description
				if($CommentStart !== FALSE){
  				if($CommaPos > $CommentStart){ $CommaPos = FALSE; }
  				if($Equal > $CommentStart){    $Equal = FALSE; }
				}
				
				//If there is no comment, probally has comment before it or has none
				if($CommentStart !== FALSE){
					if($CommentEnd === FALSE){
					
						$PerComment[] = trim( substr( $line, $CommentStart + $CommentLenght ) );
            			$MultiLineComment = true;
                        
          			} else {
            			$PerComment[] = trim( substr( $line, $CommentStart + $CommentLenght , $CommentEnd - $CommentStart - $CommentLenght ) );
          			}	
				}
				
				if($Equal !== FALSE){
  
          			if($CommaPos === FALSE){
          
	            		if($CommentStart === FALSE){
			              //Something like: Abc = 5
			              $Value = trim( substr( $line, $Equal + 1) );
			            } else {
			              //Something like: Abc = 5 /* comment */
			              $Value = trim( substr( $line, $Equal + 1, $CommentStart - $Equal - 1 ) );
			            }
            
	          		} else {
	            		//Something like: Abc = 5, /* comment */
	            		$Value = trim( substr( $line, $Equal + 1, $CommaPos - $Equal - 1 ) );
	          		}
          
          			$VariableName = trim( substr( $line, 0, $Equal - 1) );
          			$CurrentValue = $Value + 1;
      
        		} else {
          			$Value = $CurrentValue;
          			$CurrentValue++;
          
          
         		 	if($CommaPos === FALSE){
            
            			if($CommentStart === FALSE){
              				$VariableName = trim( substr( $line, 0, $Equal ) ) ;
            			} else {
              				$VariableName = trim( substr( $line, 0, $CommentStart) );
            			}
            
          			} else {
            			$VariableName = trim( substr( $line, 0, $CommaPos) );
          			}
          
          
        		}
        
		        if($MultiLineComment == false){
		          //$this->Values[ $VariableName ] = Array( $Value, $PerComment );       

					$newdefine = new Define;
					$newdefine->FromEnum($this->Parent(), $this, $i, $VariableName, $Value, $PerComment);	
		        	
					$PerComment = Array();
			        $Value = 0;
		            $VariableName = "";
		        }
        	
			}

	 	}
		
		$this->Description = str_replace(Array("@section","@endsection"), Array('',''), $this->Description );	 	
	 	
	}
		
}



class NativeFunction{
 	//[0] = Starts
 	//[1] = comment end
 	//[2] = Actual end
 	var $LineNum = Array();
 	
  	//0 = native, 1 = stock, 2 = functag, 3 = funcenum, 4 = forward
 	var $FuncType;
 	
 	var $MysqlId = -1;
 	
	var $Name = "";
	var $FullFunc = "";	
	
	var $Description = Array();
	var $Input = Array();
	var $Return = ""; //@return / @noreturn
	var $OnError = ""; //@error
	var $Deprecated = false;
	var $Extra; //For the stuff in { } in stock functions
	
	
	function GetDescription(){
		return implode( "\n", $this->Description );
	}
	
	function ParentId(){
		return $this->Parent()->MysqlId;
	}
	
	function GetInput(){
		return json_encode ( $this->Input );
	}
	
	function GetInsertQuery(){
		return sprintf("REPLACE INTO `sm_natives`(`name`, `fullname`, `description`,`input`, `return`, `onerror`, `deprecated`, `extra`,`owner`,`line`,`version`,`build`) VALUES
			('%s','%s','%s','%s','%s','%s',%d,'%s',%d,%d,'%s',%d)",
			mysql_real_escape_string( $this->Name ),
			mysql_real_escape_string( $this->FullFunc ),
			mysql_real_escape_string( $this->GetDescription() ),
			mysql_real_escape_string( $this->GetInput() ),
			mysql_real_escape_string( $this->Return ),
			mysql_real_escape_string( $this->OnError ),
			(int) $this->Deprecated,
			mysql_real_escape_string( $this->Extra ),
			$this->ParentId(),
			$this->LineNum[0],
			GetVersion(),
			GetBuild()
		);		
	}
	
	function DoSuperQuery(){
		$query = $this->GetInsertQuery();
		
		$result = db_query( $query );	
		
		if (!$result) {
		    echo  'Invalid query: ' . mysql_error() . "\n";
		    echo 'Whole query: ' . $query;
		    echo "\n\n\n";
		}		
	}
	
	function PrintInformation(){
		echo '<table border="1">';
		echo '<tr><td>Func</td><td>'. $this->Name . '</td></tr>';
		echo '<tr><td>FullFunc</td><td>'. $this->FullFunc . '</td></tr>';
		echo '<tr><td>Description</td><td>', print_r($this->Description) , '</td></tr>';
		echo '<tr><td>Input</td><td>', print_r($this->Input) , '</td></tr>';
		echo '<tr><td>OnError</td><td>'. $this->OnError . '</td></tr>';
		echo '</table>';
 	}
	
 	private $parent;
	function Parent($who = ''){
		if($who != ''){
			$this->parent = $who;
			return;
		}
		
		return $this->parent;
	}
	
	function SetLines($start, $end, $fncType){
	 	if($start == 0){
			$start = $end;
		}
	 
	 	$this->LineNum[0] = $start;
		$this->LineNum[1] = $end;
		$this->FuncType = $fncType;
		
		$FoundEndFullFunc = false;
		$StockStem = false;
		
		for($i = $start; $i <= $end; $i++){
		 	if(!isset($this->Parent()->FileContent[ $i ])) break;
		 	
		 	$line = $this->Parent()->FileContent[ $i ];
		 	
		 	if($i >= $this->LineNum[1]){
			 	
				 if(!$FoundEndFullFunc){			
					$FoundEndFullFunc = strpos( $line, ")" ) !== false;
					
					//Last line, remove the ";" or "{" or w/e else there is on the front
					if($FoundEndFullFunc){
						$this->FullFunc .= substr($line,0, strpos( $line, ")" ) + 1);
						
						if($this->FuncType == 1){
							$this->Extra .= substr($line, strpos( $line, ")" ) + 1);
						}
						
					} else {
						$this->FullFunc .= $line;
					}
				} else {
				 
				 	if($this->FuncType == 1){
						$this->Extra .= $line;
					}
					
				}
				
			}
			
			//Stocks end in "}", others end in ";"
			if($this->FuncType == 1 || $this->FuncType == 3){
			 
				if($line[0] == "}")
					break;
					
				$end++;
				
			} else {
			 	//Case if it is a function that contains more then 1 line
				if($i == $end && strpos($line, ";") === FALSE)
					$end++;
			}
		}
		
		//Case if it is a stock, and the end line changed;
		$this->LineNum[2] = $end;
		
		
		//Get the line with the function information
		$name = $this->Parent()->FileContent[ $this->LineNum[1] ];
		$NameStart = strpos( $name, " ");
		
		
		//Get just the function name
		if($this->FuncType == 2){
		 	$NameEnd = strpos( $name, " ",$NameStart + 1);
		 
		 	$this->Name = trim( substr( $name, $NameStart, $NameEnd - $NameStart ) );
		
		}elseif($this->FuncType == 3)
			$this->Name = trim( substr( $name, $NameStart) );
	
		else{
			
			$NameEnd = strpos( $name, "(");
			$name = substr( $name , $NameStart, $NameEnd - $NameStart);
			
			//Find it there is any "Float:" or something of the type
			if(($NameStart = strpos($name, ":")) !== FALSE ){
				$name = substr( $name, $NameStart + 1);
			}
			
			//And just trim and save it...
			$this->Name = trim($name);
		}
		

		$InputStarted = false;
		$LastInput = "";
		
		//If it started where it ended, it does not have any comments.
		if($this->LineNum[0] == $this->LineNum[1]) return;
		
		
		//Get the description + input
		//foreach($this->AllLines as $line){
		for($i = $this->LineNum[0]; $i <= $this->LineNum[2]; $i++){
			$line = $this->Parent()->FileContent[ $i ];
		
			$Trimmed = trim($line);
			
			if($Trimmed == "/**")
				continue;
			
			if($Trimmed == "*/"){				
				break;
			}
				
			//remove the " * "
			$line = substr($line, 3);
			
			//WTH is a "@brief" and "@note are basiacly more description"
			if(substr($line, 0, 6) == "@brief")
				$line = substr($line, 7);
			elseif(substr($line, 0, 5) == "@note")
				$line = substr($line, 6);
			
			$HasAT = $line[0] == "@";
			
			
			//Stay false, until it becomes true
			if($InputStarted == false)
				$InputStarted = $HasAT;	
			
			
			
			if($InputStarted == false){
				//If the first letter is not uppercase, then it is a continuation from the last line.
				if( strtoupper( $line[0] ) == $line[0] ){
					$this->Description[] = trim($line);
				} else {				 
			 		$this->Description[ count($this->Description) - 1 ] .= trim($line);
				}
				
			} else {
			 	$line = trim($line);
			 	
			 	if($line == "@noreturn")
			 		continue;
			 	
				//Remove the "tab"s with spaces
				$line = str_replace("\x09", " ", $line);
				
				$exploded = explode(" ", $line, 3);
				
				foreach($exploded as $id => $dummy){
					if(trim($dummy) == "")
						unset($exploded[$id]);
				}
				
				
				//if there is not nothing left, why continue?
				if(count($exploded) == 0)
					continue;
				
				if($exploded[0] == "@return" || $exploded[0] == "@noreturn"){
				 	//Bad coding, w/e...
				 	$LastInput = "@return";
					$this->Return = trim ( substr( $line, strlen($exploded[0]) + 1 ) );
					continue;
				}
				
				if($exploded[0] == "@error"){
				 	$LastInput = "@error";
					$this->OnError = trim ( substr( $line, strlen($exploded[0]) + 1 ) );
					continue;
				}
				
				if($exploded[0] == "@deprecated"){
				 	$LastInput = "@deprecated";
					$this->Deprecated = trim ( substr( $line, strlen($exploded[0]) + 1 ) );
					continue;
				}
				
			 
				if(!$HasAT){
				 
				 	if(!isset($this->Input[ $LastInput ])){
				 		switch($LastInput){
							case "@return":
								$this->Return .= "\n" . trim ( $line );								
								break;
							case "@error":
								$this->OnError .= "\n" . trim ( $line );
								break;
							case "@deprecated":
								$this->Deprecated .= "\n" . trim ( substr( $line, strlen($exploded[0]) + 1 ) );
								break;
						}
					}
					else
						$this->Input[ $LastInput ] .= "\n" . trim( $line );	
					


				} else {
				 
				 	//TODO: SetVariantEntity AND IsMapValid has wrong "@param" syntax					
					if(!isset($exploded[1])){
				 		$exploded[1] = "param";
					}
					
					//Blame SQLTCallback for this, only function with a "@param" with nothing in front of it
					if(!isset($exploded[2])){
				 		continue;
					}
				 
				 
					$LastInput = $exploded[1];
					
					$this->Input[ $exploded[1] ] = trim( $exploded[2] );
					
				}
			}
		}
	}
}




$IncludeFiles = Array();
$IncludeDir = "include";



$d = dir( $IncludeDir );

while (false !== ($entry = $d->read())) {
	if($entry == "." || $entry == "..") continue;
	if( substr($entry, -3) != "inc") continue;
 
	$file = new IncludeFile;
	$file->SetFile( $IncludeDir . "/" . $entry );
   
	$IncludeFiles[ $file->Name ] = $file;
}

$d->close();


echo 'Files read in: ' . (microtime(true) - $time_start) . "\n";
//echo '<br> Max Memory usage: ' . memory_get_peak_usage (true);


$host="localhost";        //host name or ip address 
$user="sm";        //database user name
$pass="";        //database password
$database="sm";    //dateabase name with which you want to connect

# get connection with mysql
$dblink = @mysql_connect($host,$user,$pass);

if (!$dblink) {
    die('Could not connect: ' . mysql_error());
}
# select and open database
mysql_select_db($database,$dblink);


$result = db_query('SELECT id, name FROM sm_files');
while ($row = mysql_fetch_assoc($result)) {
	if(isset( $IncludeFiles[ $row['name'] ] )){
		$IncludeFiles[ $row['name'] ]->SetMysqlId( $row['id'] );		
	} else {
		//If it is not set, the function no longer exists.
		db_query('UPDATE sm_files SET deprached = 1 WHERE id = ' . $row['id']);
	}
}

foreach($IncludeFiles as $item){
	if($item->MysqlId == -1){
	 	$item->MysqlInsert();	
	} else {
		$item->MysqlUpdate();
	}
}




$result = db_query('SELECT id, name FROM sm_natives');
while ($row = mysql_fetch_assoc($result)) {
	if(isset( $GlobalNatives[ $row['name'] ] )){
		$GlobalNatives[ $row['name'] ]->MysqlId = $row['id'];		
	} else {
		//If it is not set, the function no longer exists.
		db_query('UPDATE sm_functions SET deprecated = 1 WHERE id = ' . $row['id']);	
	}
}



$result = db_query('SELECT id, name FROM sm_enums');
while ($row = mysql_fetch_assoc($result)) {
	if(isset( $GlobalEnums[ $row['name'] ] )){
		$GlobalEnums[ $row['name'] ]->MysqlId = $row['id'];		
	} else {
		//If it is not set, the function no longer exists.
		db_query('UPDATE sm_enums SET deprecated = 1 WHERE id = ' . $row['id']);	
	}
}


$result = db_query('SELECT id, name FROM sm_defines');
while ($row = mysql_fetch_assoc($result)) {
	if(isset( $GlobalDefines[ $row['name'] ] )){
		$GlobalDefines[ $row['name'] ]->MysqlId = $row['id'];		
	} else {
		//If it is not set, the function no longer exists.
		db_query('UPDATE sm_enums SET deprecated = 1 WHERE id = ' . $row['id']);	
	}
}


foreach($GlobalNatives as $item){
	$item->DoSuperQuery();
}
foreach($GlobalEnums as $item){
	$item->DoSuperQuery();
}
foreach($GlobalDefines as $item){
	$item->DoSuperQuery();
}




echo 'Program finished in: ' . (microtime(true) - $time_start) . "\n";
echo "Peak memory: ". round(memory_get_peak_usage() / 1048576, 1) . " Megabytes\n";
echo $QueriesExecuted . " MySQL Queries\n\n"; 

?>
